<!--头部-->
<?php include('header.php');?>

<!--主体-->
<div class=main>
	<!--左边目录-->
	<?php include('leftMenu.php');?>
	
	<div class=right>
		<?php
			//拼装地址,并打印
			if(''==$trueFileName){$trueFileName='暂时没有数据';};
			#$filepath= 'data/' . $keyword . '/' . $trueFileName;
			$filepath= BLOG_MENU .'/'. $keyword . '/' . $trueFileName;
			
			$filemtime='';
			if(file_exists($filepath) ) {
				$filemtime = date('Y-m-d H:i:s', filemtime($filepath));
			}
			
			
			#echo '<p class="filepath">'.$filepath . ' [lastModified: ' . $filemtime . ']</p>';
			echo '<p class="filepath">'.$keyword . '/' . $trueFileName . ' [lastModified: ' . $filemtime . ']</p>';

			//拼装图片文件夹
			//$picturePath='data/' . $keyword . '/';


//添加左下角目录
$cornerContents = <<<ET
<div id="common_box">
	<div id="cli_title" class=title> Contents <b id="cli_on">+</b></div>
	<div id="f_content" class=container>
		<div class=content></div>
		<div class="title">==This is the bottom==</div>
	</div>
</div>
ET;

//markdown中的代码高亮
$highLightCode = <<<ET
<!--高亮代码-->
<link rel="stylesheet" type="text/css" href="/public/css/highlight-routeros.css" media="all">
<script type="text/javascript" src="/public/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();

// 代码前添加行号
addEvent(window, 'load', function(){
    //1. get pre code
    var aPre=document.getElementsByTagName('pre');
    var aCode=[]
    for(var i=0;i<aPre.length;i++){
    var oPre=aPre[i]
    var aCode1=oPre.getElementsByTagName('code');
    if(1== aCode1.length){
        var oCode=aCode1[0]
        aCode.push(oCode)
        //2. get text inside
        var lines=oCode.innerHTML.split("\\n")
        var n=lines.length;
        //console.log('i=',i, lines, '; n=',n)

		//3.make a dom of numbering
		var oUl=document.createElement('ul');
		oUl.setAttribute('class', 'pre-numbering');
		for(var j=0;j<n;j++){
			var oLi=document.createElement('li');
			oLi.innerHTML=j+1;
			oUl.append(oLi)
		}
		//4. add to code
		oPre.append(oUl)
		oCode.setAttribute('class', oCode.getAttribute('class')+ ' has-numbering')
        oPre.setAttribute('class', 'prettyprint')
	}
}
})

</script>
ET;

			//包含文章视图文件
			if(file_exists($filepath)){
				if('txt'==$fileType){//txt文件
					echo '<div class="content"><pre class=markLight>';//更改txt的样式/wiki /ubuntu1/simple/grey/mark/markLight/
					echo Dawn::showTxt($filepath);
					echo '</pre></div>';
					echo $cornerContents;
				}elseif('md'==$fileType || 'markdown'==$fileType){ //md文件
					$text = file_get_contents($filepath);
					$parser = new HyperDown\Parser();
					$html = $parser->makeHtml($text);
					echo '<div class=markdown>',$html,'</div>', $cornerContents;
					echo $highLightCode;
				}else{//其他文件
					include($filepath);
				}
			}else{
				echo '<div class=alert>该文章暂时未公开，请稍后再来...</div>';
			} 
		
		?>


<?php if($web_status==1){?>
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<?php echo $filepath;?>" data-title="请替换成文章的标题" data-url="请替换成文章的网址"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"dawneve"};
(function() {
	var ds = document.createElement('script');
	ds.type = 'text/javascript';ds.async = true;
	ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
	ds.charset = 'UTF-8';
	(document.getElementsByTagName('head')[0] 
	 || document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
<?php }?>


	</div>
</div>

<div class=clear></div>

<!--尾部-->
<?php include('footer.php');?>
